package cn.jtfadmin.core.modules.sys.domain.entity;

import cn.jtfadmin.base.data.jpa.domain.entity.BaseEntity;
import cn.jtfadmin.core.enums.LogTypeEnum;
import cn.jtfadmin.core.enums.OperateTypeEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;


@Getter
@Setter
@ToString(callSuper = true)
@Entity
@Table(name = "sys_log", indexes = {@Index(columnList = "log_type"),
        @Index(columnList = "username")})
public class SysLogEntity extends BaseEntity {


    /**
     *
     */
    private static final long serialVersionUID = 1L;

    /**
     * 耗时
     */
    @Column(name = "cost_time")
    private Long costTime;

    /**
     * IP
     */
    @Column(name = "ip")
    private String ip;

    /**
     * 请求参数
     */
    @Column(name = "request_param")
    @Lob
    private String requestParam;


    /**
     * 请求类型,application/json / formdata 等
     */
    @Column(name = "request_type")
    private String requestType;

    /**
     * 请求路径
     */
    @Column(name = "request_url")
    private String requestUrl;
    /**
     * 请求方法 get post ...
     */
    @Column(name = "method")
    private String method;

    /**
     * 操作人用户名称 姓名或昵称
     */
    @Column(name = "username", length = 100)
    private String username;
    /**
     * 操作人用户账户
     */
    @Column(name = "user_id")
    private String userId;

    /**
     * 用户类型
     */
    @Column(name = "user_type")
    private String userType;

    /**
     * 机构id
     */
    @Column(name = "org_id")
    private String orgId;

    /**
     * 归属机构名称
     */
    private String orgName;


    /**
     * 操作详细日志
     */
    @Column(name = "log_content")
    private String logContent;

    /**
     * 日志类型（1登录日志，2操作日志）
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "log_type", length = 10)
    private LogTypeEnum logType;

    /**
     * 操作类型（1 新增, 2 修改, 3 删除）
     */
    @Column(name = "operate_type")
    @Enumerated(EnumType.STRING)
    private OperateTypeEnum operateType;

    /**
     * 异常内容
     */
    @Column(name = "ex_content")
    @Lob
    private String exContent;

}
